import matplotlib.pyplot as plt
import numpy as np
import time

Lissajous_frequency = 30000 
Lissajous_Ampliyude = 512 

# Create a blank white image
# plt.figure(facecolor='white')
ax = plt.gca()
ax.set_aspect(1)
plt.xlabel('Lissajous_cos')
plt.ylabel('Lissajous_sin')
plt.title('Lissajous Scatter Plot')
plt.xlim(-1.1 * Lissajous_Ampliyude, 1.1 * Lissajous_Ampliyude)
plt.ylim(-1.1 * Lissajous_Ampliyude, 1.1 * Lissajous_Ampliyude)
plt.grid(True)
start = time.time()
while True:
    now_time = time.time()-start
    # 计算cos和sin值
    Lissajous_cos = int(Lissajous_Ampliyude * np.cos(2 * np.pi *Lissajous_frequency* now_time+np.pi/2))
    Lissajous_sin = int(Lissajous_Ampliyude * np.sin(2 * np.pi *Lissajous_frequency* now_time))

    # 绘制散点图
    plt.scatter(Lissajous_cos, Lissajous_sin, c='b', marker='o')

    plt.pause(0.001)
